import request from "../../utils/request.js";

// 用户注册
export const usersRegisterService = (registerData) => {
    const params = new URLSearchParams()
    params.append('userName', registerData.userName)
    params.append('password', registerData.password)
    params.append('email', registerData.email)
    return request.post('/user/register', params);
}
//注册邮箱
export const registerEmailService=(email)=>{
    const params = new URLSearchParams()
    params.append('email', email)
    return request.post('/user/register/sendCode', params);
}
//验证注册验证码
export const registerIdentifyingService=(emailData)=>{
    const params = new URLSearchParams()
    params.append('email', emailData.email)
    params.append('code', emailData.code)
    return request.post('/user/register/identifying', params);
}
//用户登录
export const usersLoginService = (loginData) => {
    const params = new URLSearchParams()
    params.append('userName', loginData.userName)
    params.append('password', loginData.password)
    return request.post('/auth/loginWithUsernamePassword', params);
}
//用户邮箱登录第一步
export const usersUseEmailLoginStepOneService=(email)=>{
    const params = new URLSearchParams()
    params.append('email', email)
    return request.post('/auth/loginWithEmailStepOne', params);
}
//用户邮箱登录第二步
export const usersUseEmailLoginStepTwoService=(emailData)=>{
    const params = new URLSearchParams()
    params.append('email', emailData.email)
    params.append('code', emailData.code)
    return request.post('/auth/loginWithEmailStepTwo', params);
}

// 重置密码步骤一：发送验证码
export const resetPwdStep1Service = (email) => {
    const params = new URLSearchParams()
    params.append('email', email)
    return request.post('/user/updatePwdWithEmailStepOne', params);
}

// 重置密码步骤二：验证验证码
export const resetPwdStep2Service = (data) => {
    const params = new URLSearchParams()
    params.append('email', data.email)
    params.append('code', data.code)
    return request.post('/user/updatePwdWithEmailStepTwo', params);
}

// 重置密码步骤三：更新密码
export const resetPwdStep3Service = (newPwd) => {
    const params = new URLSearchParams()
    params.append('newPwd', newPwd)
    return request.patch('/user/updatePwdWithEmailStepThree', params);
}